<template>
    <view class="addGoods">
        <view class="search-header">
            <view @click="handeleTo">
                <image style="width: 15rpx;height: 30rpx;" src="@/static/index2/index7.png" mode=""></image>
            </view>
            <view style="color: #FFFFFF;font-size: 32rpx;margin-right: 10rpx;">{{ title }}</view>
            <view></view>
        </view>
        <view class="width-all" style="width: 80%;">
            <Steps :steps="steps"></Steps>
        </view>
        <view class="entry-block" v-if="steps == 1">
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品是否发布') }}</view>
                </view>
                <u-switch v-model="model.status" size="40" active-color="#06C36E"></u-switch>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('商品名称') }}</view>
                </view>
                <u-input :placeholder="$t('请输入商品名称')" v-model="model.name" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品品牌') }}</view>
                </view>
                <u-input :placeholder="$t('请输入商品品牌')" v-model="model.brand" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('货物类型') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <goosTypeSelect :text="model.goods_type_name" :id="model.goods_type" @change="handeleGoodsType" />
                </view>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('商品分类') }}</view>
                </view>
                <view style="display: flex;align-items: center;" @click="handeleGoodsClass(1)">
                    <view style="color: #999999;">{{ model.productClassification }}</view>
                    <image style="width: 32rpx;height: 32rpx;margin-left: 16rpx;" src="@/static/index2/index14.png"
                        mode=""></image>
                </view>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('二级分类') }}</view>
                </view>
                <view style="display: flex;align-items: center;" @click="handeleGoodsClass(2)">
                    <view style="color: #999999;">{{ model.secondaryClassification }}</view>
                    <image style="width: 32rpx;height: 32rpx;margin-left: 16rpx;" src="@/static/index2/index14.png"
                        mode=""></image>
                </view>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('数量单位') }}</view>
                </view>
                <view style="display: flex;align-items: center;" @click="handeleGoodsClass(4)">
                    <view style="color: #999999;">{{ model.number_unit || this.$t('请选择数量单位') }}</view>
                    <image style="width: 32rpx;height: 32rpx;margin-left: 16rpx;" src="@/static/index2/index14.png"
                        mode=""></image>
                </view>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('货币类型') }}</view>
                </view>
                <view style="display: flex;align-items: center;" @click="handeleGoodsClass(3)">
                    <view style="color: #999999;">{{ model.price_unit || this.$t('请选择货币类型') }}</view>
                    <image style="width: 32rpx;height: 32rpx;margin-left: 16rpx;" src="@/static/index2/index14.png"
                        mode=""></image>
                </view>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('单价(元)') }}</view>
                </view>
                <u-input :placeholder="$t('请输入单价')" v-model="model.desire_price" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('单价重量(kg)') }}</view>
                </view>
                <u-input :placeholder="$t('请输入单价重量')" v-model="model.goods_weight" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('单价体积(m³)') }}</view>
                </view>
                <u-input :placeholder="$t('请输入单价体积')" v-model="model.goods_volume" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('单价商品最大尺寸（m)') }}</view>
                </view>
                <u-input :placeholder="$t('长*宽*高')" v-model="model.goods_size" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block1">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('起批数量') }}</view>
                </view>
                <u-input :placeholder="$t('请输入起批数量')" v-model="model.goods_num" style="margin-left: 50rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;" input-align="right"></u-input>
            </view>
            <view class="new-block2 u-margin-top-10">
                <view style="display: flex;align-items: center;">
                    <image style="width: 11rpx;height: 11rpx;margin-right: 6rpx;" src="@/static/index2/index11.png"
                        mode=""></image>
                    <view>{{ $t('商品介绍') }}</view>
                </view>
                <u-input type="textarea" :placeholder="$t('请输入商品介绍')" v-model="model.goods_brief"
                    style="background: #F6F7FB;border-radius: 15rpx;padding: 10rpx 20rpx;margin-top: 20rpx;min-height:300rpx;"
                    placeholder-style="font-size: 24rpx;color: #999999;"></u-input>
            </view>
        </view>
        <view class="entry-block" v-if="steps == 2">
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;justify-content:space-between;width: 100%;">
                    <view>{{ $t('自定义参数规格（可添加多个)') }}</view>
                    <view @click="addCustomAttr">
                        <u-icon name="plus-circle"></u-icon>
                    </view>
                </view>

            </view>
            <view class="new-block1 borderNone" v-if="model.parameter.length > 0">
                <view class="customBox width-all">
                    <view v-for="(item, index) in model.parameter" :key="index"
                        class="border-radius-10 bg-color-fff u-flex padd-10 flex-bottom">
                        <view class="u-flex-1 u-margin-right-20">
                            <view>{{ $t('参数名称') }}</view>
                            <view class="u-margin-top-20">
                                <u-input v-model="item.value1" :placeholder="$t('请输入参数名称')" height="40rpx"
                                    style="background: #F6F7FB;border-radius: 15rpx;padding: 10rpx 20rpx;"
                                    placeholder-style="font-size: 24rpx;color: #999999;"></u-input>
                            </view>
                        </view>
                        <view class="u-flex-1">
                            <view>{{ $t('参数信息') }}</view>
                            <view class="u-margin-top-20">
                                <u-input v-model="item.value2" :placeholder="$t('请输入参数信息')" height="40rpx"
                                    style="background: #F6F7FB;border-radius: 15rpx;padding: 10rpx 20rpx;"
                                    placeholder-style="font-size: 24rpx;color: #999999;"></u-input>
                            </view>
                        </view>
                        <view @click="minusCustomAttr(index)" class="u-margin-left-10">
                            <u-icon name="minus-circle" color="red"></u-icon>
                        </view>
                    </view>
                </view>
            </view>
            <view class="new-block2">
                <view style="width: 100%;height: 60rpx;line-height: 60rpx;">{{ $t('商品主图(最多1张)') }}</view>
                <!-- image  video-->
                <fileUploadVue :detail="isdisabled" :files.sync="model.logo" :max-count="1" file-type="image" />
            </view>
            <view class="new-block2">
                <view style="width: 100%;height: 60rpx;line-height: 60rpx;">{{ $t('商品详情图(最多3张)') }}</view>
                <!-- image  video-->
                <fileUploadVue :detail="isdisabled" :files.sync="model.buy_images" :max-count="3" file-type="image" />
            </view>
            <view class="new-block2">
                <view style="width: 100%;height: 60rpx;line-height: 60rpx;">{{ $t('商品视频(最多1个)') }}</view>
                <!-- image  video-->
                <fileUploadVue :detail="isdisabled" :files.sync="model.buy_videos" :max-count="1" file-type="video" />
            </view>
            <view class="new-block2">
                <view style="width: 100%;height: 60rpx;line-height: 60rpx;">{{ $t('文件上传(最多1个)') }}</view>
                <!-- image  video-->
                <fileUploadVue :detail="isdisabled" :files.sync="model.buy_files" :max-count="1" file-type="video" />
            </view>
        </view>
        <view class="entry-block" v-if="steps == 3">
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品是否发布') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.status ? this.$t('是') : this.$t('否') }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品名称') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.name }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品品牌') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.brand }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('货物类型') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.goods_type_name }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品分类') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.productClassification }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('二级分类') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.secondaryClassification }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('数量单位') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.number_unit }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('货币类型') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.price_unit }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('单价（元)') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.desire_price }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('单价重量（kg)') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.goods_weight }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('单价体积（m³)') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.goods_volume }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('单价商品最大尺寸（m)') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.good_size }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('起批数量') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">{{ model.goods_num }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('自定义参数规格') }}</view>
                </view>
                <view class="u-text-right">
                    <view style="color: #999999;" v-for="item in model.parameter" :key="item.value1">{{ item.value1 }} -
                        {{ item.value2 }}</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品介绍') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <view style="color: #999999;">商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍</view>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品主图') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <image style="width: 70rpx;height: 70rpx;margin-top: 10rpx;" v-for="item in model.logo" :key="item"
                        :src="IMAGE_URL + item" mode=""></image>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品详情图') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <image style="width: 70rpx;height: 70rpx;margin-top: 10rpx;margin-right: 10rpx;"
                        v-for="item in model.buy_images" :key="item" :src="IMAGE_URL + item" mode=""></image>
                </view>
            </view>
            <view class="new-block1 borderNone">
                <view style="display: flex;align-items: center;">
                    <view>{{ $t('商品视频') }}</view>
                </view>
                <view style="display: flex;align-items: center;">
                    <!-- /uploads/20241113/30b22fe79338fa93903bd998fc0b161c.mp4 -->
                    <video style="width: 70rpx;height: 70rpx;margin-top: 10rpx;" v-for="item in model.buy_videos"
                        :key="item" :src="IMAGE_URL + item" mode=""></video>
                </view>
            </view>
        </view>
        <view class="addCk">
            <view class="addCk-but prev" v-if="steps > 1" @click="steps--">{{ $t('上一步') }}</view>
            <view class="addCk-but" v-if="steps < 3" @click="steps++">{{ $t('下一步') }}</view>
            <view class="addCk-but" v-if="steps == 3" @click="save">{{ $t('立即创建') }}</view>
        </view>
        <!-- 商品一级分类 -->
        <u-picker @confirm="(event) => handeleConfirm(event, 1)" mode="selector" v-model="showOne" :range="sheetList"
            :confirm-text="$t('确定')" :cancel-text="$t('取消')" :range-key="lang == 'zh' ? 'name' : 'name_ru'" />
        <!-- 商品二级分类 -->
        <u-picker @confirm="(event) => handeleConfirm(event, 2)" mode="selector" v-model="showTow" :range="sheetListTow"
            :confirm-text="$t('确定')" :cancel-text="$t('取消')" :range-key="lang == 'zh' ? 'name' : 'name_ru'" />
        <!-- 货币类型 -->
        <u-picker @confirm="(event) => handeleConfirm(event, 3)" mode="selector" v-model="showCurrency"
            :default-selector="[0]" :range="currencyTypes" :confirm-text="$t('确定')" :cancel-text="$t('取消')"
            :range-key="lang == 'zh' ? 'name' : 'name_ru'" />
        <u-picker @confirm="(event) => handeleConfirm(event, 4)" mode="selector" v-model="showUnits"
            :default-selector="[0]" :range="quantityUnits" :confirm-text="$t('确定')" :cancel-text="$t('取消')"
            :range-key="lang == 'zh' ? 'name' : 'name_ru'" />
        <!-- 顶部背景色 -->
        <image style="width: 750rpx;height: 690rpx;position: absolute;top: 0;z-index: 1;"
            src="@/static/index2/20241101130857.png" mode=""></image>
    </view>
</template>

<script>
import fileUploadVue from '../components/fileUpload.vue'
import Steps from './Steps'
import goosTypeSelect from '../components/goosTypeSelect.vue'
import {
    IMAGE_URL
} from "@/config/app";
export default {
    components: {
        Steps,
        fileUploadVue,
        goosTypeSelect
    },
    data () {
        return {
            IMAGE_URL,
            currencyTypes: [{
                name: '元',
                name_ru: 'Юань'
            },
            {
                name: '卢布',
                name_ru: 'Руб.'
            },
            ],
            title: this.$t("新增商品"),
            steps: 1,
            sheetList: [], //商品一级分类
            sheetListTow: [], //商品二级分类
            quantityUnits: [], //数量单位
            showOne: false,
            showTow: false,
            showCurrency: false,
            showUnits: false,
            isdisabled: false,
            model: {
                logo: [],
                buy_images: [],
                buy_videos: [],
                buy_files: [],
                //是否发布
                status: true,
                name: '', //必填
                brand: '',
                goods_type: '',
                goods_type_name: this.$t('请选择货物类型'),//提交时删除
                secondaryClassification: this.$t('请选择二级分类'),//提交时删除
                category_id: '', //必填
                productClassification: this.$t('请选择商品分类'),//提交时删除
                p_category_id: '', //必填
                number_unit: null, //必填
                price_unit: null, //必填
                desire_price: '',
                goods_weight: '', //必填
                goods_volume: '', //必填
                goods_size: '',//提交时删除 必填
                goods_num: '', //必填
                goods_brief: '',
                parameter: [],
            },
            required: [
                { key: 'name', text: this.$t('请输入商品名称') },
                { key: 'p_category_id', text: this.$t('一级类目不能为空') },
                { key: 'category_id', text: this.$t('请选择二级分类') },
                { key: 'number_unit', text: this.$t('请选择数量单位') },
                { key: 'price_unit', text: this.$t('请选择货币类型') },
                { key: 'goods_weight', text: this.$t('请输入单价重量') },
                { key: 'goods_volume', text: this.$t('请输入单价体积') },
                { key: 'goods_num', text: this.$t('请输入起批数量') },
                { key: 'goods_brief', text: this.$t('请输入商品介绍') },
            ],
            id: '',
        };
    },
    onLoad (options) {
        // 如果是编辑进来传id 
        if (options.id) {
            //查询详情 赋值
            this.id = options.id
            //查询商品详情
            this.getGoodsDetail()
        }
    },
    onShow () {
        this.getLang()
        // 商品一级分类
        this.getSheetList()
        this.getSheetListTow()
        // 单位
        this.getUnitList()

    },
    methods: {
        //查询商品详情
        getGoodsDetail () {
            this.$u.api.transport.getGoodsDetail({
                id: this.id
            }).then(res => {
                console.log('res:', res);
                this.model = {
                    ...res,
                    goods_size: res.goods_l + '*' + res.goods_w + '*' + res.goods_h,
                    logo: res.logo.map(item => item.url),
                    buy_images: res.buy_images.map(item => item.url),
                    buy_videos: res.buy_videos.map(item => item.url),
                    buy_files: res.buy_files.map(item => item.url),
                    parameter: res[this.$t('item.parameter')]
                }
            })
        },
        //货物类型
        handeleGoodsType ({ id, title }) {
            this.model.goods_type_name = title
            this.model.goods_type = id
        },
        //验证必填项
        checkForm () {
            // 必填项
            for (const key of this.required) {
                if (!this.model[key.key]) {
                    this.$u.toast(this.$t(`请输入${this.$t(key.text)}`))
                    return false
                }
            }
            return true
        },
        //保存
        save () {
            if (!this.checkForm()) {
                return
            }
            // 整理附件上传格式
            const mapToUrlObject = arr => arr.map(item => ({ url: item }));
            let params = {
                ...this.model,
                id: this.id ? this.id : 0,
                logo: mapToUrlObject(this.model.logo),
                buy_images: mapToUrlObject(this.model.buy_images),
                buy_videos: mapToUrlObject(this.model.buy_videos),
                buy_files: mapToUrlObject(this.model.buy_files),
                goods_l: this.model.goods_size.split('*')[0],
                goods_w: this.model.goods_size.split('*')[1],
                goods_h: this.model.goods_size.split('*')[2],
                status: this.model.status ? 1 : 0,
            }
            delete params.parameter
            delete params.productClassification
            delete params.secondaryClassification
            delete params.goods_size
            delete params.goods_type_name;
            this.$u.api.transport.saveSupplierGoods(params).then(res => {
                uni.showToast({
                    title: this.$t('创建成功'),
                    icon: 'success'
                })
                //如果您 status 传的是1， 马上走接口31，进行上架发布
                if (this.model.status) {
                    this.$u.api.transport.quickRelease({ id: res }).then((_) => {
                        setTimeout(() => {
                            uni.navigateBack()
                        }, 1000)
                    })
                } else {
                    setTimeout(() => {
                        uni.navigateBack()
                    }, 1000)
                }
            })
        },
        //删除自定义属性值
        minusCustomAttr (index) {
            this.model.parameter.splice(index, 1)
        },
        //添加自定义属性值
        addCustomAttr () {
            this.model.parameter.push({
                key: '',
                value: ''
            })
        },
        // 商品一级分类
        getSheetList () {
            let data = {
                type: 'release_goods',
                pid: 0,
                needLogin: true,
                lang: this.lang,
            }
            this.$u.api.basic.getActionSheetList(data).then(res => {
                this.sheetList = res
            })
        },
        // 商品二级分类
        getSheetListTow (id) {
            let data = {
                type: 'release_goods',
                pid: id,
                needLogin: true,
                lang: this.lang,
            }
            this.$u.api.basic.getActionSheetList(data).then(res => {
                this.sheetListTow = res
            })
        },
        // 单位
        getUnitList () {
            this.$u.api.basic.getUnitList().then(res => {
                this.quantityUnits = res
            })
        },
        // 返回上一页
        handeleTo () {
            uni.navigateBack()
        },
        // 商品分类返回值
        handeleConfirm (event, param) {
            if (param == 1) { //一级分类
                const { id, name } = this.sheetList[event[0]]
                this.model.p_category_id = id;
                this.model.productClassification = name
                this.getSheetListTow(id)
            } else if (param == 2) { //二级分类
                const { id, name } = this.sheetListTow[event[0]]
                this.model.category_id = id;
                this.model.secondaryClassification = name
            } else if (param == 3) { //货币类型
                const { name, name_ru } = this.currencyTypes[event[0]]
                this.model.price_unit = this.lang == 'zh' ? name : name_ru
            } else if (param == 4) { //数量单位
                this.model.number_unit = this.quantityUnits[event[0]].name
            }
        },
        //商品分类一级控制显示和隐藏
        handeleGoodsClass (i) {
            if (i == 1) {
                this.showOne = true
            } else if (i == 2) {
                if (this.model.p_category_id == '') {
                    uni.showToast({
                        icon: 'none',
                        title: this.$t('一级类目不能为空')
                    })
                    return
                }
                this.showTow = true
            } else if (i == 3) {
                this.showCurrency = true
            } else if (i == 4) {
                this.showUnits = true
            }
        },
        getLang () {
            // 获取缓存lang当前语言值
            uni.getStorage({
                key: 'lang',
                success: res => {
                    if (res.data == 'zh') { //zh为中国，赋值0
                        this.lang = 'zh'
                    } else { //其他为俄罗斯，赋值1
                        this.lang = 'ru'
                    }
                }
            });
        },
    }
}
</script>

<style lang="less" scoped>
.customBox {
    background: #F6F7FB;
    border-radius: 30rpx;
    padding: 20rpx 30rpx;
}

.addCk {
    margin-top: 30rpx;
    width: 100%;
    height: 110rpx;
    background-color: #F1F2F4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30rpx;

    .addCk-but {
        flex: 1;
        height: 90rpx;
        border-radius: 90rpx;
        background: linear-gradient(180deg, #30F998 0%, #0D7DE2 98%);
        color: #FFFFFF;
        font-size: 28rpx;
        text-align: center;
        line-height: 90rpx;
        margin: 0 20rpx;

        &.prev {
            background: transparent;
            border: 2rpx solid #0F80E0;
            color: #0F80E0;
        }
    }
}

.addGoods {

    background-color: #F1F2F4;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;

    /* height: 100vh; */
    .search-header {
        z-index: 2;
        width: 690rpx;
        height: 133rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 40rpx;
    }

    .new-block2 {
        width: 100%;
        min-height: 160rpx;
        color: #1D1D1D;
        font-size: 24rpx;
    }

    .new-block1 {
        font-weight: normal;
        font-size: 24rpx;
        width: 100%;
        min-height: 60rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #1D1D1D;
        border-bottom: 1rpx solid #D8D8D8;

        &.borderNone {
            border: none;
        }
    }

    .entry-block {
        z-index: 2;
        width: 690rpx;
        min-height: 1160rpx;
        border-radius: 32rpx;
        background: #FFFFFF;
        margin-top: 24rpx;
        padding: 15rpx 30rpx 50rpx 30rpx;
        box-sizing: border-box;
    }
}
</style>